#pragma once
#pragma execution_character_set("utf-8")
// 本文件为utf-8 编码格式

#ifndef __LeftMenuViewController__
#define __LeftMenuViewController__

#include <iostream>
#include "CrossApp.h"
#include "../util/GDHttpUtil.h"
#include "../Base/GDRoundImageView.h"
#include "../CommonHttpManager.h"
#include "../Views/GDViewComponent.h"
#include "../DelegateClassDefine.h"
#include "../GdDefine.h"

USING_NS_CC;

class LeftMenuViewController : public CAViewController
	, public UserLoginDelegate
	, public CommonUrlImageViewDelegate
{

public:

	static LeftMenuViewController* create();

	LeftMenuViewController();

	virtual ~LeftMenuViewController();

	void onHeadeClicke(CAControl* control, CCPoint point);
	void onLoginClicke(CAControl* control, CCPoint point);
	void onLogoutClicke(CAControl* control, CCPoint point);
	void onJifenClicke(CAControl* control, CCPoint point);
	void onQianDaoClicke(CAControl* control, CCPoint point);
	void onItemClicke(CAControl* control, CCPoint point);
	void onCaCheClearClicke(int index);

	bool init();

	virtual void viewDidLoad();

	virtual void viewDidUnload();

	virtual void viewDidAppear();

	virtual void viewDidDisappear();

	virtual void onActionPerformed(LoginAction action);

	virtual void updateCheckinsStatus();

	/* ∏¸–¬ª˝∑÷ */
	void updateJiFen();

	void checkUserStatus();

	void logout(int index);

	void onQiandaoRequestFinished(const HttpResponseStatus& status, const CSJson::Value& json);

	void imageViewRequestFinished(CommonUrlImageView* imageView);

	void onCalculateCacheSize(float dt);

private:
	void addHeadForegrand();
protected:

	std::vector<std::string> m_Cpics;

	std::vector<std::string> m_Cnames;

	std::vector<int> m_CTags;

	int m_iItems;
	CAButton *m_pHeadButton;

	GDRoundImageView *m_pHeadImgView;
	CAImageView *m_pHeadImgStatus;
	std::string m_sMyInfoString;
	CALabel* m_pMyInfoLabel;
	CACollectionView* m_pCollectionView;
	CATableView * m_pTableView;
	friend class DMTabBarController;
	unsigned long m_uliTmpSize;

private:
	CAButton *verNodeBtn;
	int verNodeBtnClickTimes;
	CAScrollView *m_pLayoutView;
	CAView *loginNode; // µ«¬ºΩ⁄µ„
	CAView *notLoginNode; // Œ¥µ«¬ºΩ⁄µ„
	CAView *bottomNode;
	CAImageView *bgImage;
	GDButton *jifenBtn;
};


class LeftMenuViewControllerCell : public CATableViewCell
{
public:
	LeftMenuViewControllerCell();

	~LeftMenuViewControllerCell();

	bool init(const char* reuseIdentifier, const CADipSize& cellSize);

	void setItemText(std::string text);

	void setItemImage(CAImage *image);

	void setAccessToryVisible(bool visible);

	void setBotLineVisible(bool visible);
	void setType(int type);
protected:

	virtual void normalTableViewCell();

	virtual void highlightedTableViewCell();

	virtual void selectedTableViewCell();

	virtual void disabledTableViewCell();

protected:
	CALabel *m_pItemLable;

	CAImageView *m_pIemImage;

	CAImageView *m_pAccesstor;

	CAView * m_pBotLine;

	// ”“±ﬂº˝Õ∑
	CAImageView *arrowImage;
	// item ¿‡–Õ
	int type;
};


#endif /* defined(__ZhiTongCheCpp__ViewController__) */
